import { URL, fileURLToPath } from 'node:url'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv } from 'vite'
import { createViteProxy } from './build'
import qiankun from 'vite-plugin-qiankun'

export default defineConfig((configEnv)=>{
  const viteEnv = loadEnv(configEnv.mode, process.cwd())

  return {
    base: viteEnv.VITE_BASE_URL,
    plugins: [
      vue(),
      qiankun('micro-yirizhiji-app',{
        useDevMode:true
      })],
    build: {
      outDir: 'dist/yi-ri-zhi-ji-app',
    },
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
    },
    server: {
      open: true,
      proxy: createViteProxy(viteEnv),
      port: 6267,
      host: '0.0.0.0',
    },
  }

})
